package flc.ast.utils;

import android.view.View;

import com.stark.jigsaw.puzzle.PuzzleLayout;
import com.stark.jigsaw.puzzle.SquarePuzzleView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import flc.ast.R;
import stark.common.basic.view.RoundImageView;

public class PuzzleLayoutItemViewHolder extends RecyclerView.ViewHolder {

    private SquarePuzzleView mPuzzleView;
    private View mViewFrame;
    private RoundImageView mImageView;
    private int mBindPos;
    private PuzzleLayout mPuzzleLayout;


    public PuzzleLayoutItemViewHolder(@NonNull View itemView) {
        super(itemView);
        initView(itemView);
    }

    private void initView(View parent) {
        mPuzzleView = parent.findViewById(R.id.puzzleView);
        mViewFrame = parent.findViewById(R.id.view_select);
        mImageView = parent.findViewById(R.id.iv_img);
    }

    public void bindData(PuzzleLayout puzzleLayout, int pos) {
        mPuzzleLayout = puzzleLayout;
        mBindPos = pos;
        mPuzzleView.setNeedDrawLine(true);
        mPuzzleView.setNeedDrawOuterLine(true);
        mPuzzleView.setTouchEnable(false);
        mPuzzleView.setPuzzleLayout(puzzleLayout);
    }

    public int getBindPos() {
        return mBindPos;
    }

    public void showSelectView(boolean show) {
        mViewFrame.setVisibility(show ? View.VISIBLE : View.GONE);
        mImageView.setVisibility(show ? View.VISIBLE : View.GONE);
    }

    public PuzzleLayout getPuzzleLayout() {
        return mPuzzleLayout;
    }
}
